//
//  HLVisitorTableViewController.swift
//  HLWeiBo
//
//  Created by jack on 15/12/5.
//  Copyright © 2015年 jack. All rights reserved.
//

import UIKit


class HLVisitorTableViewController: UITableViewController ,HLVisitorsViewDelegate{
    //访问视图
    var visitorView = HLVisitorsView()
    //定义用户是否登录
    var userLogin = false
    
    
    //在这个方法中判断用户如果没有登录,就不执行super.loadView view 让我们自己来定义
    override func loadView() {
        userLogin ? super.loadView() : setupVisitorView()

    }
    
    //提供方法给外界使用
    private func setupVisitorView() {
        
        visitorView = HLVisitorsView()
        visitorView.delegate = self
        
        view = visitorView
        
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", target: self, action: "registerBtn")
       navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登陆", target: self, action: "loginBtn")
        
        }
    
    @objc private func registerBtn() {
    
        print("注册")
    }
    
    @objc private func loginBtn() {
        print("登陆")
        let nav = UINavigationController(rootViewController: HLOAuthViewController())

        presentViewController(nav, animated: true, completion: nil)

    }
    
    internal func visitorLogin() {
    
        loginBtn()
    }
    internal func visitorRegister() {
    
        registerBtn()
    }
    
    override func viewDidLoad() {
        
        super.viewDidLoad()

    }

    

}
